<?php

namespace App\Http\Controllers\WebApp;

use Carbon\Carbon;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use EasyWeChat;
use Log;

class HomeController extends Controller
{
    public function index()
    {
        $wx_config = [];
        try {
            $wechat = EasyWeChat::officialAccount();
            $wx_config = $wechat->jssdk->buildConfig(array('onMenuShareQQ', 'onMenuShareWeibo', 'scanQRCode'), false);
        } catch (\Throwable $e) {
            Log::error('获取微信jssdk参数失败', [$e->getMessage()]);
            $wx_config = json_encode($wx_config);
        }

        return view('webapp.home', [
            'wechat_user' => session('wechat.oauth_user.default'),
            'wx_config' => $wx_config
        ]);
    }
}
